package com.gm.cards.domain;

import java.util.ArrayList;
import java.util.List;

public class Round {

    private static Deck deck = new Deck();

    private Card turn;

    private int totalPlayers;

    private List<Team> teams;

    public static Deck getDeck() {
	return deck;
    }

    public static void setDeck(Deck deck) {
	Round.deck = deck;
    }

    public int getTotalPlayers() {
	return totalPlayers;
    }

    public void setTotalPlayers(int totalPlayers) {
	this.totalPlayers = totalPlayers;
    }

    public List<Team> getPlayers() {
	return teams;
    }

    public void setPlayers(List<Team> teams) {
	this.teams = teams;
    }

    public Round(int totalTeams, int playersPerTeam) {

	this.totalPlayers = totalTeams * playersPerTeam;
	deck.setExcludes(new ArrayList<Card>());
	this.turn = deck.getRandomCard();
	System.out.println("Turned: " + turn.getNumber() + " " + turn.getSuit() + " position: " + turn.getPositionOnDeck());

	deck.adjustWeights(this.turn);

	this.teams = new ArrayList<Team>();
	for (int i = 0; i < totalTeams; i++) {
	    List<Player> players = new ArrayList<Player>();
	    for (int j = 0; j < playersPerTeam; j++) {
		players.add(new Player(i, deck));
		System.out.println("Team " + i + "-" + "Player " + j);
		for (int k = 0; k < 3; k++) {
		    Card a = players.get(j).getCards().get(k);
		    System.out.println(a.getNumber() + " " + a.getSuit() + " " + a.getPositionOnDeck() + " " + a.getWeight());
		}
		System.out.println();
	    }
	    teams.add(new Team(players));
	}
    }

    public void showCard(Card card) {

    }
}
